let prefix
if (process.env.NODE_ENV == 'development') {
	prefix = 'https://192.168.1.1'
} else{
	prefix = 'https://192.168.1.12'
}



export function requestApi(url, method, data) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + url,
			method,
			data,
			success(res) {
				if (res.statusCode == 200) {
					resolve(res.data)
					if (res.data.code == 600) {
							uni.showModal({
								title: '提示',
								content: '登录已过期，请重新登录',
								confirmText: '重新登录',
								confirmColor: '#91B0F7',
								showCancel: false,
								success() {
									uni.clearStorage()
									uni.reLaunch({
										url: '/pages/login/login'
									})
								}
							})
					}
				} else {
					reject('其他错误')
					uni.showToast({
						title: '服务器连接错误',
						icon: 'none',
						duration: 2000
					})
				}
			},
			fail(err) {
				reject(err)
			}
			
			
			
			
			
		})
	})
}